package com.lanou.pianke.admin.web.controller;

import com.lanou.pianke.admin.entity.User;
import com.lanou.pianke.admin.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/")
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private ArticleService articleService;
    @Autowired
    private ArticleCommentService articleCommentService;
    @Autowired
    private AreplyService areplyService;
    @Autowired
    private PieceService pieceService;
    @Autowired
    private PcommentService pcommentService;
    @Autowired
    private PreplyService preplyService;

//    @GetMapping("showUsers")
//    public List<User> showUsers(){
//        List<User> userList = userService.showAll();
//        return userList;
//    }

    // 查看所有被举报用户
    @GetMapping("showUsersReported")
    public List<User> showUsersReported(){
        return userService.showReported();
    }

    // 删除全部被举报用户
    // @PathVariable 获取url中的数据
    //@RequestParam 获取请求参数的值
    @DeleteMapping("deleteUser")
    public String deleteUser(){
        userService.delete();
        return "删除用户成功";
    }

    // 删除某个用户,及用户发表的文章,碎片,评论,回复
//    @DeleteMapping("deleteUserByUid/{uid}")
//    public String deleteUserByUid(@PathVariable Long uid){
//        userService.deleteUserByUid(uid);
//        // 根据uid删除文章
//        articleService.deleteArticleByUid(uid);
//        // 根据uid删除文章评论
//        articleCommentService.deleteByUid(uid);
//        // 根据uid删除文章回复
//
//        areplyService.deleteByUid(uid);
//        // 根据uid删除碎片
//        pieceService.deleteByUid(uid);
//        // 根据uid删除碎片评论
//        pcommentService.deleteByUid(uid);
//        // 根据uid删除碎片回复
//        preplyService.deleteByUid(uid);
//        return "删除用户成功";
//    }
}
